#ifndef __FHTTPD_RETURN_JSON_OBJECT_H__
#define __FHTTPD_RETURN_JSON_OBJECT_H__
#include <string>
#include <memory>
#include "face_api_helper.h"
#include "json/json.h"
#include "return_object_if.h"

using namespace std;

class RetFaceAttr : public BaseObjectIf
{
public:
    RetFaceAttr(int code,const std::string& msg):
		BaseObjectIf(code,msg)
	{

	}
	void setAttr(const face_attr_t & ar){
		attr = ar;
	}
    
	virtual Json::Value Convert2JsonValue();

protected:
	face_attr_t attr;
};


class RetFaceQuality : public  BaseObjectIf 
{

public:
    RetFaceQuality(int code,const std::string& msg):
		BaseObjectIf(code,msg)
	{

	}

	void setQuality(face_quality_t q) {
		quality = q;
	}
    virtual Json::Value Convert2JsonValue();

protected:
    face_quality_t quality;       
};


class RetFaceInfo : public SerializeIf 
{
public:
	RetFaceInfo(float rx,float ry,float rw,float rh,const std::string& image):
		x(rx),y(ry),width(rw),height(rh),img(image)
	{

	}
	virtual Json::Value Convert2JsonValue();
protected:
	float x;
	float y;
	float width;
	float height;
	std::string img; //base64
};


class RetMultFaceTrackInfo : public BaseObjectIf
{
public:
	RetMultFaceTrackInfo(int code,const std::string& message):
		BaseObjectIf(code,message)
	{

	}

	int AddFaceInfo(const RetFaceInfo& info);
	virtual Json::Value Convert2JsonValue();
protected:

	int count;
	bool retFaceImg;
	std::vector<RetFaceInfo> faces; 
};



class RetFaceFeature : public BaseObjectIf
{
public:
	RetFaceFeature(int code,const std::string& message):
		BaseObjectIf(code,message)
	{

	}

	void setFeature(const std::vector<float>& fs) {
		features = fs;
	}
	
	virtual Json::Value Convert2JsonValue();

protected:
	std::vector<float> features; 

};


class RetMatchFace : public BaseObjectIf
{
public:
	RetMatchFace(int code,const std::string& message):
		BaseObjectIf(code,message)
	{

	}

	void setScore(float s){
		score = s;
	}
	virtual Json::Value Convert2JsonValue();

private:
	float score;
};


class RetRegisterFace : public BaseObjectIf
{
public:
	RetRegisterFace(int code,const std::string& message):
		BaseObjectIf(code,message)
	{

	}
	virtual Json::Value Convert2JsonValue();

};


class RetSearchFace : public BaseObjectIf
{
public:
	RetSearchFace(int code,const std::string& message):
		BaseObjectIf(code,message),	
		score(0.000)
	{
	}
	virtual Json::Value Convert2JsonValue();

	void setFaceId(const std::string& id)
	{
		face_id = id;
	}

	void setFaceKey(const std::string& key)
	{
		face_key = key;
	}

	void setScore(float s)
	{
		score = s;
	}
private:	
	std::string face_id;
	std::string face_key;
	float score;
};

typedef struct search_return_{
	std::string img_name;
	std::string face_id;
	std::string face_key;
	float score;
}search_return_t;


class RetMultSearchFace : public BaseObjectIf
{
public:
	RetMultSearchFace(int code,const std::string& message):
		BaseObjectIf(code,message)
	{
	}
	virtual Json::Value Convert2JsonValue();

	void setSearched(const std::map<std::string,search_return_t>& s){
		searched = s;
	}
private:	
	std::map<std::string,search_return_t> searched;
};


class RetRemoveFace : public BaseObjectIf
{
public:
	RetRemoveFace(int code,const std::string& message):
		BaseObjectIf(code,message)
	{

	}
	virtual Json::Value Convert2JsonValue();

};

class RetClearFaces : public BaseObjectIf
{
public:
	RetClearFaces(int code,const std::string& message):
		BaseObjectIf(code,message)
	{

	}
	virtual Json::Value Convert2JsonValue();

};

class RetNoHandler : public BaseObjectIf
{
public:
	RetNoHandler(int code,const std::string& message):
		BaseObjectIf(code,message)
	{

	}
	virtual Json::Value Convert2JsonValue();

};


std::string Serialize(shared_ptr<BaseObjectIf> object);

#endif

